<script lang="ts" setup>
import {ref} from 'vue'
 //导入element-plus组件的图标(:icon="")
    import {Delete,Edit} from '@element-plus/icons-vue'
    const currentPage = ref(1)//当前页
    const pageSize4 = ref(5)//初始的每页显示条数
    const small = ref(false)//分页条大小
    const background = ref(false)
    const disabled = ref(false)
    const total=ref(20)
    const handleSizeChange = (val: number) => {
    console.log(`${val} items per page`)
    }
    const handleCurrentChange = (val: number) => {
    console.log(`current page: ${val}`)
    }
    const tableData = [
        {
        title: '标题1',
        category: '时事',
        time: '2000-01-01',
        state:'已发布'
        },
        {
        title: '标题1',
        category: '时事',
        time: '2000-01-01',
        state:'已发布'
        },
        {
        title: '标题1',
        category: '时事',
        time: '2000-01-01',
        state:'已发布'
        },
        {
        title: '标题1',
        category: '时事',
        time: '2000-01-01',
        state:'已发布'
        }
    ]

    import { reactive } from 'vue'

    const formInline = reactive({
    user: '',
    region: '',
    date: '',
    })

    const onSubmit = () => {
    console.log('submit!')
    }
 
</script>
  
<template>
    <!--整个页面被置于el-card中-->
        <el-card class="card-box">
            <div class="card-header">
                <span>文章管理</span>
                <el-button type="primary" class="button">发布文章</el-button>
            </div>

            <div style="margin-top: 20px;">
                <hr>
            </div>

            <el-form :inline="true" :model="formInline" class="demo-form-inline">
            
            <el-form-item label="文章分类">
                <el-select
                    v-model="formInline.region"
                    placeholder="请选择"
                    clearable>
                    <el-option label="时事" value="时事" />
                    <el-option label="篮球" value="篮球" />
                </el-select>
            </el-form-item>

            <el-form-item label="发布状态">
                <el-select
                    v-model="formInline.region"
                    placeholder="请选择"
                    clearable>
                    <el-option label="已发布" value="已发布" />
                    <el-option label="已发布" value="草稿" />
                </el-select>
            </el-form-item>

        <el-form-item>
        <el-button type="primary" @click="onSubmit">搜索</el-button>
        </el-form-item>
        <el-form-item>
        <el-button type="default" @click="onSubmit">重置</el-button>
        </el-form-item>

    </el-form>
    <!--表格组件-->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="title" label="文章标题" />
      <el-table-column prop="category" label="分类"/>
      <el-table-column prop="time" label="发表时间"/>
      <el-table-column prop="state" label="状态" />
      <el-table-column prop="操作" label="操作">
            <el-button type="primary" :icon="Edit"></el-button>
            <el-button type="danger" :icon="Delete"></el-button>
      </el-table-column>
    </el-table>
    <!--分页组件，layout控制分页条组件排列顺序-->
    <el-pagination class="el-p"
      v-model:current-page="currentPage"
      v-model:page-size="pageSize4"
      :page-sizes="[5, 10, 15, 20]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="jumper, sizes, prev, pager, next, total"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
        </el-card>
    
</template>
<style scoped>
/*scoped表示style只在本vue生效*/
    .el-p{
        margin-top: 20px;
        display: flex;
        justify-content: flex-end;
    }
    .demo-form-inline .el-select {
    --el-select-width: 220px;
    }
    .card-header{
        display: flex;
        justify-content: space-between;
    }
</style>